// 入驻申请
<template>
   <div class="search">
     <Row>
        <Card>
          <Row class="operation">
            <Form inline :label-width="100" ref="searchForm" :model="searchForm" label-position="right">
              <Button @click="getDataList()" icon="md-refresh">刷新</Button>
            </Form>
          </Row>
          <Modal title="查看大图" v-model="visible" class-name="fl-image-modal">
            <img :src="imgUrl" v-if="visible" style="width: 100%">
          </Modal>

          <Row>
            <Table :loading="loading" border :columns="columns" :data="data" ref="table" sortable="custom" @on-sort-change="changeSort"></Table>
          </Row>

          <Row type="flex" justify="end" class="page">
            <Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10,20,50]" size="small" show-total show-elevator show-sizer></Page>
          </Row>
        </Card>
     </Row>
   </div> 
</template>

<script>
export default {
  data(){
    return{ 
      submitLoading: false,
      visible:false,
      total:0,
      modalTitle: "",
      loading: true, // 表单加载状态
      data:[],//表单数据
      searchForm:{
        pageSize:10,
        pageNumber:1
      },
      columns: [
      // 表头
      {
        type: "index",
        width: 60,
        align: "center"
      },
      {
        title: "客户昵称",
        key: "nickName",
        minWidth: 120,
        sortable: false,
      },
      {
        title: "客户头像",
        key: "avatar",
        minWidth: 120,
        sortable: false,
        render: (h, params) => {
          return h("img", {
            style:{
              width:'60px',
              height:'40px',
            },
            attrs:{
              src:params.row.avatar,
            },
            on:{
              click:(e)=>{
                console.log(e)
                this.handleView(e.srcElement.currentSrc)
              }
            }
          });
        }
      },
      {
        title: "性别",
        key: "sex",
        minWidth: 120,
        sortable: false,
        render:(h,params)=> {
            if (params.row.sex == "1") {
                return h("span", "男")
            } else if (params.row.sex == "0") {
                return h("span", "女")
            }
        }
      },
      {
        title: "婚期",
        key: "weddingDay",
        minWidth: 120,
        sortable: false,
      },
      
      {
        title: "订单次数",
        key: "serviceCount",
        minWidth: 120,
        sortable: false,
      },
      {
          title: "操作",
          width: 160,
          align: "center",
          fixed: "right",
          render: (h, params) => {
            return h("div", [
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.message(params.row);
                    }
                  }
                },
                "短信"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "info",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.pushData(params.row);
                    }
                  }
                },
                "推送"
              ),
            ]);
          }
        }
      ],
      }
    },
    methods:{
      init(){
        this.getDataList()
      },
      handleView(url) {
        this.imgUrl = url;
        this.visible = true;
      },
      getDataList(){
        this.postRequest("/appUser/getStoreAccurateCustomer",this.searchForm).then(res =>{
          this.loading = false
          if(res.success){
            this.data = res.result.dataResult;
            this.total = res.result.totalNumber;
          } else {
            this.data = [];
            this.total = 0;
          }
        })
      },
      changeSort(e) {
        this.searchForm.sort = e.key;
        this.searchForm.order = e.order;
        if (e.order === "normal") {
          this.searchForm.order = "";
        }
        this.getDataList();
      },
      changePage(v) {
        this.searchForm.pageNumber = v;
        this.getDataList();
      },
      changePageSize(v) {
        this.searchForm.pageSize = v;
        this.getDataList();
      },
      clearSelectAll(){
        this.$refs.searchForm.resetFields()
        this.getDataList()
      },
    },
    mounted(){
      this.init()
    }
}
</script>

<style lang="less">
.search {
    .operation {
        margin-bottom: 2vh;
    }
    .select-count {
        font-size: 13px;
        font-weight: 600;  
        color: #40a9ff;
    }
    .select-clear {
        margin-left: 10px;
    }
    .page {
        margin-top: 2vh;
    }
    .drop-down {
        font-size: 13px;
        margin-left: 5px;
    }
}
</style>